﻿using System;

namespace EnterpriseLibraryExtensions.Events
{
    /// <summary>
    /// The interface for handling an event in the eventing system. 
    /// Implement interface to be able to register a class as an event handler.
    /// </summary>
    public interface IHandlesEvent
    {
        /// <summary>
        /// Gets the type of event that the event handler can handle.
        /// </summary>
        Type EventType { get; }

        /// <summary>
        /// Gets a value indicating whether the event handlers can run async or not. 
        /// There is no guarantee that the event handler will actually be invoked on a different thread - that is determined by ParallelFX.
        /// </summary>
        bool ExecuteAsync { get; }

        /// <summary>
        /// Method is called when the event of type EventType is raised.
        /// </summary>
        /// <param name="sender">The instance that raised the event. The value might be null.</param>
        /// <param name="args">The arguments of type EventType associated with the event. Value cannot be null.</param>
        void OnEvent(object sender, object args);
    }
}
